package com.qs.home.ui.activity;

import android.os.Bundle;
import android.view.View;

import com.alibaba.android.arouter.facade.annotation.Autowired;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.qs.base.base.BaseMyActivity;
import com.qs.base.router.RouterActivityPath;
import com.qs.home.BR;
import com.qs.home.R;
import com.qs.home.databinding.HomeSelectLanguageBinding;
import com.qs.home.ui.VM.SelectLanguageItemViewModel;
import com.qs.home.ui.VM.SelectLanguageViewModel;

import java.util.ArrayList;
import java.util.List;

import me.goldze.mvvmhabit.bus.RxBus;
import me.goldze.mvvmhabit.utils.StringUtils;

/**
 * 翻译语种选择
 *
 * @Author ltzz
 * @Date 2019/8/21
 */
@Route(path = RouterActivityPath.Home.SELECT_LANGUAGE)
public class SelectLanguageActivity extends BaseMyActivity<HomeSelectLanguageBinding, SelectLanguageViewModel> {
    @Autowired()
    String language;

    @Override
    protected boolean statusBarDarkFont() {
        return true;
    }

    @Override
    protected View titleLayout() {
        return null;
    }

    @Override
    public int initContentView(Bundle savedInstanceState) {
        return R.layout.home_select_language;
    }

    @Override
    public int initVariableId() {
        return BR.viewModel;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        binding.head.setAutoFinish(this);
        binding.head.setTitleLeftText("选择语言");
        if (!StringUtils.isTrimEmpty(language)) {
            viewModel.selectLanguage.set(language);
        }
        setLanguageData();
    }

    public void setLanguageData() {
        List<String> strs = new ArrayList<>();
        strs.add("中文");
        strs.add("英语");
        strs.add("粤语");
        strs.add("文言文");
        strs.add("日语");
        strs.add("韩语");
        strs.add("法语");
        strs.add("西班牙语");
        strs.add("泰语");
        strs.add("阿拉伯语");
        strs.add("俄语");
        strs.add("葡萄牙语");
        strs.add("德语");
        strs.add("意大利语");
        strs.add("希腊语");
        strs.add("荷兰语");
        strs.add("波兰语");
        strs.add("保加利亚语");
        strs.add("爱沙尼亚语");
        strs.add("丹麦语");
        strs.add("芬兰语");
        strs.add("捷克语");
        strs.add("罗马尼亚语");
        strs.add("斯洛文尼亚语");
        strs.add("瑞典语");
        strs.add("匈牙利语");
        strs.add("繁体中文");
        strs.add("越南语");
        for (int i = 0; i < strs.size(); i++) {
            viewModel.observableList.add(new SelectLanguageItemViewModel(viewModel, strs.get(i)));
        }
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        RxBus.getDefault().post(viewModel.selectLanguage.get());
    }
}
